import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;

/*
    java.io.PrintStream:标准的字节输出流，默认输出到控制台

 */
public class PrintStreamTest {
    public static void main(String[] args) throws FileNotFoundException {
        //联合写
        System.out.println("我爱文梦甜");

        //分开写
        PrintStream ps = System.out;
        ps.println("我爱");
        ps.println("文梦");
        ps.println("甜");

        //标准输出流不需要手动close关闭
        //其实可以改变标准输出流的输出方向
        //标准输出流指向log文件
        PrintStream printStream = new PrintStream(new FileOutputStream("chapter21//log"));
        //修改输出方向
        System.setOut(printStream);
        System.out.println("我");
        System.out.println("爱");
        System.out.println("文");
        System.out.println("梦");
        System.out.println("甜");

    }
}
